#!/usr/bin/env bash

docker container inspect mysql > /dev/null  2>&1

if [ $? -eq 0 ]; then
		echo "skip docker mysql"
		exit
fi

host=$1
if [ -z "$host" ]
then
  host='http://dev8.cn:8000/static/ops'
fi

mkdir -p /opt/docker

wget $host/mysql.conf -P /opt/docker -N
wget $host/mysql-dump.sh -P /opt/docker -N

docker volume create mysql_data

docker run --name mysql -d \
-e MYSQL_ROOT_PASSWORD=1234.5678 \
--net mynet --ip 172.72.0.10 \
-p 8306:3306 \
-v /opt/docker/mysql.conf:/etc/mysql/conf.d/my_master.cnf \
-v mysql_data:/data \
mariadb


docker cp /opt/docker/mysql-dump.sh mysql:/usr/local/bin/mysql-dump.sh
docker exec mysql chmod a+x /usr/local/bin/mysql-dump.sh

# curl -fsSL http://dev8.cn:8000/static/ops/docker-mysql.sh | bash